﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using AthCommander.Model;
using System.IO;

namespace AthCommander.DirectoryGrid.Dialogs
{
    public partial class DeleteDialog : Form
    {
        private FileView _file;

        public DeleteDialog(FileView file)
        {
            InitializeComponent();
            _file = file;
            deleteName.Text = _file.Name;
        }

        #region Private Helpers

        private void Delete()
        {
            if (_file.IsDirectory)
            {
                Directory.Delete(_file.FullName, true);
            }
            else
            {
                File.Delete(_file.FullName);
            }
        }

        #endregion

        #region Event Handlers

        private void deleteButton_Click(object sender, EventArgs e)
        {
            try
            {
                Delete();
                this.Close();
            }
            catch (Exception error)
            {
                MessageBox.Show(error.Message);
            }
        }

        private void cancelButton_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        #endregion


    }
}
